package sample.testDispose
{

	import org.abc.uiCore.AbcBtn;
	import org.abc.uiCore.TimeLineView;

	import flash.display.Sprite;
	import flash.events.MouseEvent;

	/**
	 * @describe  	...
	 * @author  	Mr.zheng
	 * @website 	http://blog.sina.com.cn/zihua2007
	 * @time		2011-8-11 13:10
	 */
	public class TestDispose extends Sprite
	{
		private var _contain:Sprite;

		public function TestDispose()
		{
			_contain=new Sprite();
			addChild(_contain);

			var btn:AbcBtn=new AbcBtn(new BtnMc);
			btn.name="btn";
			this.addChild(btn);
			btn.addEventListener(MouseEvent.CLICK, onBtnClick);

			var btn2:AbcBtn=new AbcBtn(new BtnMc);
			btn2.name="btn2";
			btn2.x=100;
			this.addChild(btn2);
			btn2.addEventListener(MouseEvent.CLICK, onBtnClick);

		}

		/* public function */

		/* override function */

		/* private function */
		private function onBtnClick(e:MouseEvent):void
		{
			var animal:TimeLineView;
			if (e.currentTarget.name == "btn")
			{
				for (var i:int=0; i < 100; i++)
				{
					animal=new TimeLineView(new AnimalMc);
					animal.x=Math.random() * 500;
					animal.y=Math.random() * 400;
					_contain.addChild(animal);
				}
			}
			var len:int=_contain.numChildren;
			if (e.currentTarget.name == "btn2")
			{
				for (var j:int=0; j < len; j++)
				{
					animal=_contain.getChildAt(0) as TimeLineView;
					if (animal)
						animal.dispose();
				}
			}

		}
	}

}
